package com.atguigui.leetcode1;

/**
 * 2455.可被三整除的偶数的平均值
 * Project: leetcode
 * Package: com.atguigui.leetcode1
 * Version: 1.0
 * <p>
 * Created by WJX on 2023/5/29 9:00
 */
public class P2455AverageValueOfEvenNumbersThatAreDivisibleByThree {
    public static void main(String[] args) {
        Solution solution = new P2455AverageValueOfEvenNumbersThatAreDivisibleByThree().new Solution();
        // TO TEST
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int averageValue(int[] nums) {
            var sum = 0;
            var size = 0;

            for (int num : nums) {
                if (num % 3 == 0 && num % 2 == 0) {
                    sum += num;
                    size++;
                }
            }
            return size == 0 ? 0 : sum / size;
        }
    }
}
